-- scripts/init.lua

-- 执行lua脚本
local function __load_asset_script__(filename)
    local script_filename = LuaGui.FileSystem.FormatPath(LuaGui.GetScriptDirectory() .. "/" .. filename);
    local lua_text = LuaGui.GetScriptTextByFilePath(script_filename);
    --LuaGui.Log.Info("script_filename:" .. script_filename);
    --LuaGui.Log.Info("script_text:" .. lua_text);
    xpcall(function()
        local func, errmsg = load(lua_text, script_filename, "bt");
        if (not func) then
            LuaGui.Log.Error(errmsg);
            LuaGui.Log.Error("load: " .. script_filename .. " failed");
        else
            func();
        end
    end, function(errmsg)
        LuaGui.Log.Error(errmsg);
        debug.traceback();
    end);
end

LuaGui.Log.Debug("=========================scipts init============================");

-- 加载commonlib
__load_asset_script__("commonlib/init.lua");
commonlib.import(commonlib.__script_directory__ .. "/window/init.lua");
commonlib.import(commonlib.__script_directory__ .. "/blockly/init.lua");
commonlib.import(commonlib.__script_directory__ .. "/ui/init.lua");
commonlib.import(commonlib.__script_directory__ .. "/webserver/init.lua");
commonlib.import(commonlib.__script_directory__  .. "/app/init.lua");

